makefile:变量无法正确扩展 |
您所在的位置:网站首页 › Makefile 变量 › makefile:变量无法正确扩展 |
百度翻译此文
有道翻译此文
问题描述
I am having a problem with this Makefile structure. make commit.install should create foo.txt and then put it into some folder. However, make doesn't call the target that creates foo.text. This means I have to call make foo.txt to create the file itself and then call make commit.install to copy this over. I think there is a problem with make not expanding variable dependencies. ./common.mk src.install: ${INSTALLSRC} mkdir -p result for f in ${INSTALLSRC}; do \ cp -a $$f result/.; \ done commit.install: src.install echo "finished" clean: rm -rf result./inner/nested/GNUmakefile include ../common.mk include Makefile./inner/nested/Makefile SRC=foo.txt foo.txt: echo "hello world" > foo.txt./inner/common.mk include ../../common.mk INSTALLSRC=${SRC}Repository 推荐答案The problem is that you define INSTALLSRC after the rule that has it as a prerequisite. So when Make evaluates the prerequisite list, the variable is empty, so Make sees no need to build foo.txt. This would have been pretty obvious if you had simplified this collection of makefiles. The fix is simple; swap the two lines in inner/common.mk: INSTALLSRC=${SRC} include ../../common.mkand GNUMakefile: include Makefile include ../common.mk |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |